package br.com.firula.dao.hibernate;

import java.util.List;

import org.springframework.stereotype.Repository;

import br.com.firula.dao.TimeDAO;
import br.com.firula.to.TimeTO;

@Repository("timeDAO")
public class TimeDAOHibernate extends GenericDAOHibernate implements TimeDAO {

	private static final long serialVersionUID = 6007655568681859966L;

    public TimeTO getTimePorNome(String nome){
		List times = getHibernateTemplate().find("from TimeTO t where t.nomeCurto ilike ? and (t.removido is null or t.removido = ?)", new Object[]{nome, Boolean.FALSE});
    	if(times == null || times.size() == 0)
			return null;
		else{
			return (TimeTO)times.get(0);
		}
    }

    public List<TimeTO> getTodosTimes(){
		List times = getHibernateTemplate().find("from TimeTO t where (removido is null or removido = ?)", new Object[]{Boolean.FALSE});
		return times;
    }

}
